const complainService = require('../service/complainService')
class ComplainController {
  async createComplain(ctx, next) {
    const { content,state,resultId } = ctx.request.body 
    await complainService.createComplain( content,state,resultId)
    ctx.body = {
      msg:"success"
    }
  }
  async getComplainList(ctx, next) {
    const { pagenum, pagesize, state } = ctx.request.body  
    const res = await complainService.getComplainList(pagenum, pagesize, state)
    ctx.body = {
      data: {
        ...res,
        pagenum
      }
    }
  }
  async resolveComplain(ctx, next) {
    const { id } = ctx.params 
    const {feedback} = ctx.request.body
    await complainService.resolveComplain(id,feedback)
    ctx.body = {
      msg:'success'
    }
  }
  async removeComplain(ctx, next) {
    const { id } = ctx.params
    await complainService.removeComplain(id)
    ctx.body = {
      msg:'success'
    }
  }
}

module.exports = new ComplainController()